package com.hf.cllectiontools;

public class Student implements Comparable<Student>{
    /**
     * 姓名
     */
    private String stuName;
    /**
     * 学号
     */
    private String stuNum;
    /**
     * 成绩
     */
    private double stuSore;

    public Student() {
    }

    public Student(String stuName, String stuNum, double stuSore) {
        this.stuName = stuName;
        this.stuNum = stuNum;
        this.stuSore = stuSore;
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public String getStuNum() {
        return stuNum;
    }

    public void setStuNum(String stuNum) {
        this.stuNum = stuNum;
    }

    public double getStuSore() {
        return stuSore;
    }

    public void setStuSore(double stuSore) {
        this.stuSore = stuSore;
    }

    @Override
    public String toString() {
        return "Student{" +
                "stuName='" + stuName + '\'' +
                ", stuNum='" + stuNum + '\'' +
                ", stuSore=" + stuSore +
                '}';
    }

    /**
     * 重写compareTo方法
     * @param stu 形参
     * @return 1，0，-1
     */
    @Override
    public int compareTo(Student stu) {
        //比较业务逻辑i实现
        //默认值是等于
        int i = 0;
        if (this.getStuSore() > stu.getStuSore()){
            //大于
            i = 1;
        }
        if (this.getStuSore() < stu.getStuSore()){
            //小于
            i = -1;
        }
        return i;
    }
}
